using UnityEngine;
using System.Collections;

public class InteractSpaceObjectsGenerator : InteractObject
{
    public int count = 20;
    public Vector3 offset = new Vector3();

    override public void Interact(MonoBehaviour sender)
    {
        if (Input.GetKeyDown(interactButton))
        {
            // GameObject starRain = GameObject.FindGameObjectWithTag("StarRain");

            for (int index = 0; index < count; index++)
            {
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.AddComponent("Rigidbody");
                cube.tag = "FlyCube";

                Rigidbody rigidbody = (Rigidbody)cube.GetComponent("Rigidbody");
                rigidbody.useGravity = false;

                cube.transform.position = transform.position + offset;
                cube.transform.position += new Vector3(Random.Range(-3f, 3f), Random.Range(-3f, 3f), Random.Range(-3f, 3f));
            }
        }
    }
}
